package com.herenit.order_model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.util.Date;

/**
 *  失败打回细节
 */
@Data
@Entity(name = "OmFailureDetails")
@NoArgsConstructor
@AllArgsConstructor
public class OmFailureDetail {
    /**
     *  主键Id
     */
    @Id
    @SequenceGenerator(name = "failure_id_seq", sequenceName = "om_failure_details_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "failure_id_seq")
    private Long id;

    /**
     *  对应记录的Id
     */
    private Long recordId;

    /**
     *  发送失败打回的时间戳
     */
    @UpdateTimestamp
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date time;

    /**
     *  尝试获取的消息中的字符串
     */
    private String content;

    /**
     *  失败打回的原因
     */
    private String reason;

    public OmFailureDetail(Long recordId, String content, String reason) {
        this.recordId = recordId;
        this.content = content;
        this.reason = reason;
    }
}
